﻿Imports System
Imports System.Data
Imports System.String
Imports System.Text
Imports System.Collections


Public Class Frm_INTAccountInandOut
    Implements IDServer.IDServer.IDServer


    Private MasterDS As DataSet
    Private DetailDs As DataSet
    Private bFind As Boolean
    Private Fields As String
    Private DragName As String

    Private WithEvents MainForm As Frm_MainForm


#Region "Property"

    Public Property SelectObject() As Frm_MainForm
        Get
            Return MainForm
        End Get
        Set(ByVal value As Frm_MainForm)
            MainForm = value
        End Set
    End Property

#End Region


#Region "interface"

    Public Function ActionAdd() As Boolean Implements IDServer.IDServer.IDServer.ActionAdd

    End Function

    Public Function ActionCancel() As Boolean Implements IDServer.IDServer.IDServer.ActionCancel

    End Function

    Public Function ActionDelete() As Boolean Implements IDServer.IDServer.IDServer.ActionDelete

    End Function

    Public Function ActionEdit() As Boolean Implements IDServer.IDServer.IDServer.ActionEdit

    End Function

    Public Function ActionExport() As Boolean Implements IDServer.IDServer.IDServer.ActionExport
        Try
            Me.Cursor = Cursors.WaitCursor
            PrintInStoreNumDetail(Me.DGV_Master, "", "", "", "", "", "", "", "", "", 1)
            Me.Cursor = Cursors.Default
        Catch ex As Exception
            Me.Cursor = Cursors.Default
        End Try

    End Function

    Public Function ActionFilter() As Boolean Implements IDServer.IDServer.IDServer.ActionFilter
        Dim Frm_Filter As New Frm_Filter
        Me.Cursor = Cursors.WaitCursor
        Frm_Filter.LoadHeaderCaption(Fields, "Frm_INTAccountInandOut")
        Frm_Filter.ShowDialog()
        Me.Cursor = Cursors.Default
        ReBindGridCaption(Me.DGV_Master, "Frm_INTAccountInandOut")
    End Function

    Public Function ActionGoFirst() As Boolean Implements IDServer.IDServer.IDServer.ActionGoFirst

    End Function

    Public Function ActionGoLast() As Boolean Implements IDServer.IDServer.IDServer.ActionGoLast

    End Function

    Public Function ActionGoNext() As Boolean Implements IDServer.IDServer.IDServer.ActionGoNext

    End Function

    Public Function ActionGoPrevious() As Boolean Implements IDServer.IDServer.IDServer.ActionGoPrevious

    End Function

    Public Function ActionImport() As Boolean Implements IDServer.IDServer.IDServer.ActionImport

    End Function

    Public Function ActionInitialize() As Boolean Implements IDServer.IDServer.IDServer.ActionInitialize

    End Function

    Public Function ActionPrint() As Boolean Implements IDServer.IDServer.IDServer.ActionPrint
        Try

            If Me.TabControl1.SelectedIndex = 0 Then
                If MasterDS.Tables(0).Rows.Count <= 0 Then
                    MsgBox("對不起，沒有數據可列印！", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, Msg.CompanyName)
                    Exit Function
                End If
            Else
                If Me.DataGridView1.Rows.Count <= 0 Then
                    MsgBox("對不起，沒有數據可列印！", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, Msg.CompanyName)
                    Exit Function
                End If
            End If

            Dim Pathstr As String = ""
            Dim ConfigNode() As String = ReadConfigFile.Split(";")
            Dim mServer As String = ""
            Dim mDataBase As String = ""
            Dim mUserID As String = ""
            Dim mPassword As String = ""
            Dim sql As String = ""

            If Me.TabControl1.SelectedIndex = 0 Then
                If Me.cmbType.SelectedIndex = 1 = True Then
                    Pathstr = GetReportPath("Store", "AllCount.rpt")
                Else
                    Pathstr = GetReportPath("Store", "RepCount.rpt")
                End If
            Else
                Pathstr = GetReportPath("Store", "RepSinglecount.rpt")
            End If


            For i As Integer = 0 To ConfigNode.Length - 1
                If ConfigNode(i).Split("=")(0).ToLower = "Server".ToLower Then
                    mServer = ConfigNode(i).Split("=")(1)
                End If
                If ConfigNode(i).Split("=")(0).ToLower = "DataBase".ToLower Then
                    mDataBase = ConfigNode(i).Split("=")(1)
                End If
                If ConfigNode(i).Split("=")(0).ToLower = "Uid".ToLower Then
                    mUserID = ConfigNode(i).Split("=")(1)
                End If
                If ConfigNode(i).Split("=")(0).ToLower = "Pwd".ToLower Then
                    mPassword = ConfigNode(i).Split("=")(1)
                End If
            Next

            Dim myReportDoc As New CrystalDecisions.CrystalReports.Engine.ReportDocument
            Dim myParameterValues As New CrystalDecisions.Shared.ParameterValues
            Dim myDiscreteValue As New CrystalDecisions.Shared.ParameterDiscreteValue

            Dim logonInfo As New CrystalDecisions.Shared.TableLogOnInfo
            Dim table As CrystalDecisions.CrystalReports.Engine.Table
            myReportDoc.Load(Pathstr)

            For Each table In myReportDoc.Database.Tables
                logonInfo = table.LogOnInfo
                With logonInfo.ConnectionInfo
                    .ServerName = mServer
                    .DatabaseName = mDataBase
                    .UserID = mUserID
                    .Password = mPassword
                End With
                table.ApplyLogOnInfo(logonInfo)
            Next


            If Me.TabControl1.SelectedIndex = 0 Then
                If MasterDS.Tables(0).Rows.Count > 0 Then
                    myReportDoc.SetDataSource(MasterDS.Tables(0))
                End If
            Else
                myReportDoc.SetDataSource(CType(DataGridView1.DataSource, DataTable))
                myReportDoc.SetParameterValue("StartDate", FormatDate(Me.DateTimePicker2.Value))
                myReportDoc.SetParameterValue("EndDate", FormatDate(Me.DateTimePicker1.Value))
                myReportDoc.SetParameterValue("OperateMan", PubUserCode)
                myReportDoc.SetParameterValue("OperateDate", ServerDate)
            End If



            My.Forms.Frm_Report.CrystalReportViewer1.ReportSource = myReportDoc
            My.Forms.Frm_Report.CrystalReportViewer1.Zoom(1)
            My.Forms.Frm_Report.CrystalReportViewer1.DisplayGroupTree = False

            Frm_Report.ShowDialog()

        Catch ex As Exception
            MsgBox("對不起，打印出錯！" & ex.Message & ex.ToString, MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, Msg.CompanyName)
        End Try
    End Function

    Public Function ActionSave() As Boolean Implements IDServer.IDServer.IDServer.ActionSave

    End Function

    Public Function ActionSelect() As Boolean Implements IDServer.IDServer.IDServer.ActionSelect

    End Function

#End Region


#Region "function or Sub"

    Private Sub BindMasterGrid()
        Dim mTable As New DataTable
        Try
            With mTable
                .Columns.Add("ShopNo")
                .Columns.Add("BoNum")
                .Columns.Add("DeliverDate")
                .Columns.Add("Code")
                .Columns.Add("SupperItem")
                .Columns.Add("Enname")
                .Columns.Add("Cnname")
                .Columns.Add("InBatch")
                .Columns.Add("InStore")
                .Columns.Add("InCount", GetType(Decimal))
                .Columns.Add("OutBatch")
                .Columns.Add("OutStore")
                .Columns.Add("OutCount", GetType(Decimal))
            End With
            MasterDS = New DataSet
            MasterDS.Tables.Add(mTable)
            Me.DGV_Master.DataSource = MasterDS.Tables(0)

            With Me.DGV_Master
                For i As Int16 = 0 To Me.DGV_Master.Columns.Count - 1
                    Dim mKey As String = .Columns(i).Name
                    Dim CaptionStr As String = ReturnHash(0).Item(mKey)
                    If ReturnHash(0).ContainsKey(mKey) = True Then
                        .Columns(i).HeaderText = CaptionStr
                    End If
                Next
                .AllowUserToAddRows = False
                .AllowUserToDeleteRows = False
                .AllowDrop = True
                .MultiSelect = False
                .Columns("InCount").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
                .Columns("OutCount").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
            End With

            With Me.dgv_Sum
                .ReadOnly = True
                .AllowUserToAddRows = False
                .AllowUserToDeleteRows = False
                .ColumnHeadersVisible = False
                .ScrollBars = ScrollBars.Vertical
                Me.dgv_Sum.Columns.Add("ShopNo", "")
                Me.dgv_Sum.Columns.Add("BoNum", "")
                Me.dgv_Sum.Columns.Add("DeliverDate", "")
                Me.dgv_Sum.Columns.Add("GoodsBarCode", "")
                Me.dgv_Sum.Columns.Add("Code", "")
                Me.dgv_Sum.Columns.Add("SupperItem", "")
                Me.dgv_Sum.Columns.Add("Enname", "")
                Me.dgv_Sum.Columns.Add("Cnname", "")
                Me.dgv_Sum.Columns.Add("InBatch", "")
                Me.dgv_Sum.Columns.Add("InStore", "")
                Me.dgv_Sum.Columns.Add("InCount", "")
                Me.dgv_Sum.Columns.Add("OutBatch", "")
                Me.dgv_Sum.Columns.Add("OutStore", "")
                Me.dgv_Sum.Columns.Add("OutCount", "")
                Dim GridRow As New DataGridViewRow
                Me.dgv_Sum.Rows.Add(GridRow)
                .Columns("InCount").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
                .Columns("OutCount").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
            End With

            SetGridWidth()
        Catch ex As Exception
            MsgBox("BindMasterGrid:" & ex.ToString, MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly, Msg.CompanyName)
        Finally
            mTable = Nothing
        End Try

    End Sub

    Private Sub BindDetailGrid()
        Dim mTable As New DataTable
        Try
            With mTable
                .Columns.Add("StoreName")
                .Columns.Add("TradeType")
                .Columns.Add("DeliverDate")
                '.Columns.Add("PoNum")
                '.Columns.Add("GoodsBarCode")
                .Columns.Add("BarCode")
                .Columns.Add("Code")
                .Columns.Add("Enname")
                .Columns.Add("Cnname")
                .Columns.Add("SupperItem")
                .Columns.Add("Batch")
                .Columns.Add("StorePlace")
                .Columns.Add("Goodsamount")
            End With
            DetailDs = New DataSet
            DetailDs.Tables.Add(mTable)
            Me.DataGridView1.DataSource = DetailDs.Tables(0)

            With Me.DataGridView1
                For i As Integer = 0 To Me.DataGridView1.Columns.Count - 1
                    Dim mKey As String = .Columns(i).Name
                    Dim CaptionStr As String = ReturnHash(1).Item(mKey)
                    If ReturnHash(1).ContainsKey(mKey) = True Then
                        .Columns(i).HeaderText = CaptionStr
                    End If
                Next
                .AllowUserToAddRows = False
                .AllowUserToDeleteRows = False
                .SelectionMode = DataGridViewSelectionMode.FullRowSelect
                .MultiSelect = False
            End With
        Catch ex As Exception
            MsgBox("BindMasterGrid:" & ex.ToString, MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly, Msg.CompanyName)
        Finally
            mTable = Nothing
        End Try

    End Sub

    Private Sub ReBindGrid(ByVal mIndex As Integer)

        Try
            With Me.DGV_Master

                Select Case mIndex
                    Case 0
                        For i As Int16 = 0 To Me.DGV_Master.Columns.Count - 1
                            Dim mKey As String = .Columns(i).Name
                            Dim CaptionStr As String = ReturnHash(0).Item(mKey)
                            If ReturnHash(0).ContainsKey(mKey) = True Then
                                .Columns(i).HeaderText = CaptionStr
                            End If
                        Next
                    Case 1
                        For i As Int16 = 0 To Me.DGV_Master.Columns.Count - 1
                            Dim mKey As String = .Columns(i).Name
                            Dim CaptionStr As String = ReturnHash(1).Item(mKey)
                            If ReturnHash(1).ContainsKey(mKey) = True Then
                                .Columns(i).HeaderText = CaptionStr
                            End If
                        Next
                End Select


            End With

        Catch ex As Exception
            MsgBox("ReBindGrid:" & ex.Message, MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly, Msg.CompanyName)
        End Try

    End Sub

    Private Function ReturnHash(ByVal index As Integer) As Hashtable

        Dim mHash As New Hashtable
        Try

            With mHash
                Select Case index
                    Case 0
                        .Add("ShopNo", "倉庫")
                        .Add("BoNum", "入\出庫單號")
                        .Add("PoNum", "采購單號")
                        .Add("DeliverDate", "入\出庫日期")
                        .Add("Code", "貨品編碼")
                        .Add("GoodsBarCode", "貨品條碼")
                        .Add("SupperItem", "廠商型號")
                        .Add("Enname", "英文名稱")
                        .Add("Cnname", "貨品描述")
                        .Add("InBatch", "入庫批次")
                        .Add("InStore", "入庫倉位")
                        .Add("InCount", "入庫數量")
                        .Add("OutBatch", "出庫批次")
                        .Add("OutStore", "出庫倉位")
                        .Add("OutCount", "出庫數量")
                    Case 1
                        .Add("StoreName", "倉庫")
                        .Add("TradeType", "庫存類型")
                        .Add("DeliverDate", "日期")
                        .Add("Ponum", "採購單號")
                        .Add("BarCode", "貨品條碼")
                        .Add("Code", "貨品編碼")
                        .Add("Enname", "英文名稱")
                        .Add("Cnname", "貨品描述")
                        .Add("SupperItem", "廠商型號")
                        .Add("Batch", "批次")
                        .Add("StorePlace", "倉位")
                        .Add("Goodsamount", "數量")
                End Select

            End With
            Return mHash

        Catch ex As Exception
            Throw ex
        Finally
            mHash = Nothing
        End Try

    End Function

    Private Sub GetToolEnable()
        Try
            With MainForm
                .ToolStripAdd.Enabled = AddEnable
                .ToolStripEdit.Enabled = EditEnable And bFind = True
                .ToolStripDelete.Enabled = DeleteEnable And bFind = True
                .ToolStripPrint.Enabled = PrintEnable
                .ToolStripImport.Enabled = ImportEnable
                .ToolStripExport.Enabled = ExportEnable
                .ToolStripFind.Enabled = FindEnable
                .ToolStripFilter.Enabled = True
                .ToolStripCheck.Enabled = CheckEnable
                .ToolStripUnCheck.Enabled = UncheckEnable
                .ToolStripComplete.Enabled = CompleteEnable
                .AddToolStripMenuItem.Enabled = .ToolStripAdd.Enabled
                .Edit1ToolStripMenuItem.Enabled = .ToolStripEdit.Enabled
                .DelToolStripMenuItem.Enabled = .ToolStripDelete.Enabled
                .SaveToolStripMenuItem.Enabled = .ToolStripSave.Enabled
                .CancelToolStripMenuItem.Enabled = .ToolStripCancel.Enabled
                .PrintToolStripMenuItem.Enabled = .ToolStripPrint.Enabled
                .ExportToolStripMenuItem.Enabled = .ToolStripImport.Enabled
                .ImportToolStripMenuItem.Enabled = .ToolStripExport.Enabled
                .FilterToolStripMenuItem.Enabled = .ToolStripFilter.Enabled
            End With

        Catch ex As Exception
            MsgBox("GetToolEnable:" + ex.ToString, MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, Msg.CompanyName)
        End Try
    End Sub

    Private Sub LoadStore()

        Dim m_Ds As New DataSet
        Try
            Dim sql As String = "select * from BSC_StoreHouse"
            m_Ds = ReturnDataset(sql)
            Me.ComboBox1.DisplayMember = "fShortName"
            Me.ComboBox1.ValueMember = "fCode"
            Me.ComboBox1.DataSource = m_Ds.Tables(0)

            Me.ComboBox3.DisplayMember = "fShortName"
            Me.ComboBox3.ValueMember = "fCode"
            Me.ComboBox3.DataSource = CType(Me.ComboBox1.DataSource, DataTable)
            Me.ComboBox3.DropDownStyle = ComboBoxStyle.DropDownList
            Me.ComboBox3.SelectedIndex = 0

            Dim aTable As DataTable = CType(Me.ComboBox1.DataSource, DataTable)
            Me.ComboBox2.DisplayMember = "fShortName"
            Me.ComboBox2.ValueMember = "fCode"
            Me.ComboBox2.DataSource = aTable
            Me.ComboBox2.DropDownStyle = ComboBoxStyle.DropDownList
            Me.ComboBox2.SelectedIndex = 0

            With Me.ComboBox4
                .Items.Add("<未選定>")
                .Items.Add("入庫")
                .Items.Add("出庫")
                .DropDownStyle = ComboBoxStyle.DropDownList
                .SelectedIndex = 0
            End With
            aTable = Nothing
        Catch ex As Exception
            Throw ex
        Finally
            m_Ds = Nothing
        End Try

    End Sub

    Private Sub LoadStatType()

        Try
            With Me.cmbType
                .Items.Add("查看明細")
                .Items.Add("綜合統計")
            End With
            Me.cmbType.SelectedIndex = 0
            Me.cmbType.DropDownStyle = ComboBoxStyle.DropDownList

            With Me.cmbQtype
                .Items.Add("<未選擇>")
                .Items.Add("入庫")
                .Items.Add("出庫")
                .Items.Add("期初庫存")
            End With
            Me.cmbQtype.DropDownStyle = ComboBoxStyle.DropDownList
            Me.cmbQtype.SelectedIndex = 0
        Catch ex As Exception

        End Try

    End Sub

    ''' <summary>
    ''' 
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub SetGridWidth()

        Try
            For i As Integer = 1 To Me.DGV_Master.Columns.Count - 1
                Me.dgv_Sum.Columns(i).Width = Me.DGV_Master.Columns(i).Width
            Next
        Catch ex As Exception
            MsgBox("SetGridWidth:" + ex.ToString, MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly, Msg.CompanyName)
        End Try
    End Sub


#End Region


#Region "Control Events"

    ''' <summary>
    ''' 
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub Frm_INTAccountInandOut_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Try
            BindMasterGrid()
            BindDetailGrid()
            SetGridCaptionVisible(Me.DGV_Master, Fields, "Frm_INTAccountInandOut")
            LoadStore()
            LoadStatType()
        Catch ex As Exception
            MsgBox("對不起，加載窗體出錯！", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, Msg.CompanyName)
        End Try

    End Sub

    ''' <summary>
    ''' 
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub btnFind_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnFind.Click

        Try
            ExecuteFind()

        Catch ex As Exception
            MsgBox("對不起，查詢出錯！", MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly, Msg.CompanyName)
        End Try

    End Sub

    ''' <summary>
    ''' 
    ''' </summary>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Private Function ExecuteFind() As Boolean

        Dim sql As String = ""
        Dim whereStr As String = ""
        Dim conditionStr As String = ""
        Dim StartDate As String = ""
        Dim EndDate As String = ""
        Try
            Me.Cursor = Cursors.WaitCursor
            StartDate = FormatDate(Me.StartDate1.Value)
            EndDate = FormatDate(Me.EndDate1.Value)
            If Me.CheckBox1.Checked = False And Me.CheckBox2.Checked = False Then
                MsgBox("請選擇要查詢的日期！", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, Msg.CompanyName)
                Exit Function
            ElseIf Me.CheckBox1.Checked = True And Me.CheckBox2.Checked = False Then
                conditionStr += " and Convert(varchar(10),DeliverDate,21)='" & StartDate & "'"
            ElseIf Me.CheckBox1.Checked = False And Me.CheckBox2.Checked = True Then
                conditionStr += " and Convert(varchar(10),DeliverDate,21)='" & EndDate & "'"
            Else
                conditionStr += " and Convert(varchar(10),DeliverDate,21) between '" & StartDate & "' and '" & EndDate & "'"
            End If

            If Me.CheckBox1.Text.Length > 0 Then
                'whereStr += " and b.BarCode='*" & Me.TextBox1.Text & "*'"
            End If

            If Me.cmbType.SelectedIndex = 2 Then
                If Me.ComboBox1.Text.Trim <> "" Then
                    whereStr += " and a.ToStore='" & Me.ComboBox1.SelectedValue.ToString & "'"
                End If
            Else
                If Me.ComboBox1.Text.Trim <> "" Then
                    whereStr += " and a.ShopNo='" & Me.ComboBox1.SelectedValue.ToString & "'"
                End If
            End If

            If Me.TextBox1.Text.Length > 0 Then
                whereStr += " and b.BarCode='*" & Me.TextBox1.Text & "*'"
            End If

            If Me.TextBox2.Text.Length > 0 Then
                whereStr += " and b.SupperItem='" & Me.TextBox2.Text.Replace("'", "") & "'"
            End If

            If Me.TextBox3.Text.Length > 0 Then
                whereStr += " and a.InBatch='" & Me.TextBox3.Text & "'"
            End If

            If Me.TextBox4.Text.Length > 0 Then
                whereStr += " and isnull(a.InStore,'')='" & Me.TextBox4.Text & "'"
            End If

            If Me.TextBox5.Text.Length > 0 Then
                whereStr += " and a.OutBatch='" & Me.TextBox5.Text & "'"
            End If

            If Me.TextBox6.Text.Length > 0 Then
                whereStr += " and isnull(a.OutStore,'') ='" & Me.TextBox6.Text & "'"
            End If



            If Me.cmbType.SelectedIndex = 2 Then
                If Me.TextBox7.Text.Length > 0 Then
                    whereStr += " and isnull(b.PoNum,'') ='" & Me.TextBox7.Text & "'"
                End If

                sql = "select f.fShortName as ShopNo,b.BoNum,b.PoNum,c.Code,Replace(c.BarCode,'*','') as GoodsBarCode,c.SupperItem,c.Enname,c.Cnname,b.Batch as InBatch,b.Storeplace as InStore,b.Goodsamount as InCount from Stor_TradeMaster a inner join Stor_TradeDetail b on a.BoNum=b.BoNum "
                sql += " left join dbo.BSC_Goods c on b.GoodsBarcode=c.Barcode "
                sql += " inner join dbo.BSC_ColorDefine d on c.Color=d.ColorCode "
                sql += " inner join dbo.BSC_SizeDefine e on c.Spec=e.SizeCode "
                sql += " left join dbo.BSC_StoreHouse f on a.ToStore=f.fCode "
                sql += " where isnull(a.TradeType,'')='+' and isnull(b.PoNum,'')<>''" & whereStr
            ElseIf Me.cmbType.SelectedIndex = 0 Then
                sql = "select e.fShortName as ShopNo,BoNum,DeliverDate,Replace(a.GoodsBarCode,'*','') as GoodsBarCode,b.Code,b.SupperItem,b.Enname,b.Cnname,a.InBatch,a.InStore,a.InCount,a.OutBatch,a.OutStore,a.OutCount from "
                sql += " (select ShopNo=case when isnull(m.FromStore,'')<>'' then m.FromStore when isnull(n.ToStore,'')<>'' then n.ToStore end,"
                sql += " BoNum=case when isnull(m.BoNum,'')<>'' and isnull(n.BoNum,'')<>'' then m.BoNum+'\'+n.BoNum when isnull(m.BoNum,'')='' and isnull(n.BoNum,'')<>'' then n.BoNum when isnull(m.BoNum,'')<>'' and isnull(n.BoNum,'')='' then m.BoNum else ''end,"
                sql += " DeliverDate=case when isnull(m.DeliverDate,'')<>'' and isnull(n.DeliverDate,'')<>'' then m.DeliverDate+'\'+n.DeliverDate when isnull(m.DeliverDate,'')='' and isnull(n.DeliverDate,'')<>'' then n.DeliverDate when isnull(m.DeliverDate,'')<>'' and isnull(n.DeliverDate,'')='' then m.DeliverDate else ''end,"
                sql += " GoodsBarCode=case when isnull(m.DeliverDate,'')<>'' and isnull(n.DeliverDate,'')<>'' then m.GoodsBarcode when isnull(m.DeliverDate,'')='' and isnull(n.DeliverDate,'')<>'' then n.GoodsBarCode when isnull(m.DeliverDate,'')<>'' and isnull(n.DeliverDate,'')='' then m.GoodsBarcode else ''end,"
                sql += " InBatch=case when isnull(n.BoNum,'')<>'' then n.Batch else '' end,"
                sql += " InStore=case when isnull(n.BoNum,'')<>'' then n.Storeplace else '' end,"
                sql += " InCount=case when isnull(n.BoNum,'')<>'' then n.Goodsamount else 0 end,"
                sql += " OutBatch=case when isnull(m.BoNum,'')<>'' then m.Batch else '' end,"
                sql += " OutStore=case when isnull(m.BoNum,'')<>'' then m.Storeplace else '' end,"
                sql += " OutCount=Case when isnull(m.BoNum,'')<>'' then m.Goodsamount else 0 end from"
                sql += " (select a.FromStore,b.BoNum,DeliverDate,b.GoodsBarcode,b.Batch,b.Storeplace,sum(b.Goodsamount) as Goodsamount from Stor_TradeMaster a inner join Stor_TradeDetail b on a.BoNum=b.BoNum where a.TradeType='-' and isnull(b.SmNum,'')=''" & conditionStr & " group by a.FromStore,b.BoNum,GoodsBarCode,b.Batch,b.Storeplace,DeliverDate) m full outer join "
                sql += " (select a.ToStore,b.BoNum,DeliverDate,b.GoodsBarcode,b.Batch,b.Storeplace,sum(b.Goodsamount) as Goodsamount from Stor_TradeMaster a inner join Stor_TradeDetail b on a.BoNum=b.BoNum where a.TradeType='+' and isnull(b.SmNum,'')='' " & conditionStr & " group by a.ToStore,b.BoNum,GoodsBarCode,b.Batch,b.Storeplace,DeliverDate) n on m.GoodsBarcode=n.GoodsBarcode and m.DeliverDate=n.DeliverDate and m.BoNum=n.BoNum)"
                sql += " a left join dbo.BSC_Goods b on a.GoodsBarcode=b.Barcode inner join dbo.BSC_ColorDefine c on b.Color=c.ColorCode inner join dbo.BSC_SizeDefine d on b.Spec=d.SizeCode left join dbo.BSC_StoreHouse e on a.ShopNo=e.fCode where 1=1" & whereStr & "order by DeliverDate"
            ElseIf Me.cmbType.SelectedIndex = 1 Then
                sql = "select e.fShortName as ShopNo,TradeType=case a.TradeType when '+' then '入庫' when '-' then '出庫'end,a.DeliverDate,b.Code,Replace(b.BarCode,'*','') as GoodsBarCode,b.SupperItem,b.Enname,b.Cnname,a.Batch,a.Storeplace,a.Goodsamount,isnull(g.Goodsamount,0) as GoodsCount from "
                sql += " (select a.FromStore as ShopNo,a.TradeType,DeliverDate,b.GoodsBarcode,b.Batch,b.Storeplace,sum(b.Goodsamount) as Goodsamount from Stor_TradeMaster a inner join Stor_TradeDetail b on a.BoNum=b.BoNum where a.TradeType='-'" & conditionStr & " group by a.TradeType,a.FromStore,GoodsBarCode,b.Batch,b.Storeplace,DeliverDate"
                sql += " union all"
                sql += " select a.ToStore as ShopNo,a.TradeType,DeliverDate,b.GoodsBarcode,b.Batch,b.Storeplace,sum(b.Goodsamount) as Goodsamount from Stor_TradeMaster a inner join Stor_TradeDetail b on a.BoNum=b.BoNum where a.TradeType='+'" & conditionStr & " group by a.TradeType,a.ToStore,GoodsBarCode,b.Batch,b.Storeplace,DeliverDate) a"
                sql += " Left Join"
                sql += " (select Period,StoreHouse,BarCode,Batch,StorePlace,sum(Goodsamount) as Goodsamount from V_VisualStoreQuery group by StoreHouse,Period,barcode,Batch,StorePlace) g"
                sql += " on a.ShopNo=g.StoreHouse and a.GoodsBarCode=g.Barcode and a.Batch=g.Batch and a.StorePlace=g.StorePlace"
                sql += " left join dbo.BSC_Goods b on a.GoodsBarcode=b.Barcode inner join dbo.BSC_ColorDefine c on b.Color=c.ColorCode inner join dbo.BSC_SizeDefine d on b.Spec=d.SizeCode left join dbo.BSC_StoreHouse e on a.ShopNo=e.fCode where 1=1" & whereStr & "order by DeliverDate"

            End If

            MasterDS = ReturnDataset(sql)
            Me.DGV_Master.DataSource = MasterDS.Tables(0)
            If Me.cmbType.SelectedIndex = 1 Then
                ReBindGrid(1)
            Else
                ReBindGrid(0)
            End If
            If Me.cmbType.SelectedIndex = 0 Then
                If MasterDS.Tables(0).Rows.Count > 0 Then
                    Me.dgv_Sum.Rows(0).Cells("InCount").Value = Format(MasterDS.Tables(0).Compute("sum(InCount)", ""), "#0.00")
                    Me.dgv_Sum.Rows(0).Cells("OutCount").Value = Format(MasterDS.Tables(0).Compute("sum(OutCount)", ""), "#0.00")
                Else
                    Me.dgv_Sum.Rows(0).Cells("InCount").Value = "0.00"
                    Me.dgv_Sum.Rows(0).Cells("OutCount").Value = "0.00"
                End If
            ElseIf Me.cmbType.SelectedIndex = 1 Then

            ElseIf Me.cmbType.SelectedIndex = 2 Then

            End If

            bFind = MasterDS.Tables(0).Rows.Count > 0
            GetToolEnable()
            Me.Cursor = Cursors.Default
            Return True
        Catch ex As Exception
            MsgBox("ExecuteFind:" & ex.Message, MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly, Msg.CompanyName)
            Me.Cursor = Cursors.Default
        Finally
            Me.Cursor = Cursors.Default
        End Try

    End Function

    ''' <summary>
    ''' 
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub cmbType_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbType.SelectedIndexChanged

        Try
            'If Me.cmbType.SelectedIndex = 0 Then
            '    Me.DGV_Master.Columns("Batch").Visible = False
            '    Me.DGV_Master.Columns("TradeType").Visible = False
            '    Me.DGV_Master.Columns("Storeplace").Visible = False
            '    Me.DGV_Master.Columns("Goodsamount").Visible = False
            '    Me.DGV_Master.Columns("GoodsCount").Visible = False
            'ElseIf Me.cmbType.SelectedIndex = 1 Then
            '    Me.DGV_Master.Columns("TradeType").Visible = True
            '    Me.DGV_Master.Columns("Batch").Visible = True
            '    Me.DGV_Master.Columns("Storeplace").Visible = True
            '    Me.DGV_Master.Columns("Goodsamount").Visible = True
            '    Me.DGV_Master.Columns("GoodsCount").Visible = True
            '    Me.DGV_Master.Columns("InBatch").Visible = False
            '    Me.DGV_Master.Columns("InStore").Visible = False
            '    Me.DGV_Master.Columns("InCount").Visible = False
            '    Me.DGV_Master.Columns("OutBatch").Visible = False
            '    Me.DGV_Master.Columns("OutStore").Visible = False
            '    Me.DGV_Master.Columns("OutCount").Visible = False
            'End If
        Catch ex As Exception
            MsgBox("cmbType_SelectedIndexChanged:" & ex.Message, MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly, Msg.CompanyName)
        End Try

    End Sub

    ''' <summary>
    ''' 
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub DGV_Master_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DGV_Master.CellClick

        Dim sql As String = ""
        Dim CurrentGoodsBarCode As String = ""
        Dim ShopNo As String = ""
        Try



            If Me.cmbType.SelectedIndex = 1 Then
                'ShopNo = Me.DGV_Master.CurrentRow.Cells("StoreHouse").Value
                'CurrentGoodsBarCode = Me.DGV_Master.CurrentRow.Cells("GoodsBarCode").Value

                'sql = "select BeginQty,Batch,StorePlace,Goodsamount from "
                'sql += "(select Period,StoreHouse, BarCode, Batch,StorePlace,sum(BeginQty) as BeginQty,sum(Goodsamount) as Goodsamount from V_Storequery group by StoreHouse,Period,barcode,Batch,StorePlace) a where StoreHouse='" & ShopNo & "' and BarCode='*" & CurrentGoodsBarCode & "*'"

                'DetailDs = ReturnDataset(sql)
                'Me.DataGridView1.DataSource = DetailDs.Tables(0)


            End If
        Catch ex As Exception
            MsgBox("DGV_Master_CellClick:" & ex.Message, MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly, Msg.CompanyName)
        End Try

    End Sub

    ''' <summary>
    ''' 
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub DGV_Master_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles DGV_Master.KeyDown

        Try
            Select Case e.KeyCode
                Case Keys.Up
                    DGV_Master_CellClick(Nothing, Nothing)
                Case Keys.Down
                    DGV_Master_CellClick(Nothing, Nothing)
            End Select

        Catch ex As Exception
            MsgBox("DGV_Master_KeyDown:" & ex.Message, MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly, Msg.CompanyName)
        End Try

    End Sub

    ''' <summary>
    ''' 
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub DGV_Master_RowPostPaint(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewRowPostPaintEventArgs) Handles DGV_Master.RowPostPaint

        Try
            e.Graphics.DrawString(e.RowIndex + 1, Me.DGV_Master.DefaultCellStyle.Font, Brushes.Black, e.RowBounds.Location.X + 5, e.RowBounds.Location.Y + 4)
        Catch ex As Exception
            MsgBox("DGV_Master_RowPostPaint:", MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly, Msg.CompanyName)
        End Try

    End Sub

    ''' <summary>
    ''' 
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub btnSelect_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSelect.Click

        Try

            Dim sql As String = ""
            Dim WhereStr As String = ""
            Dim WhereStr2 As String = ""
            Dim DateStr As String = ""
            Dim mType As String = ""
            Dim StoreName As String = Me.ComboBox3.SelectedValue.ToString
            Me.Cursor = Cursors.WaitCursor
            If Me.CheckBox3.Checked = True And Me.CheckBox4.Checked = True Then
                DateStr = "and Convert(varchar(10),DeliverDate,21) between '" & FormatDate(Me.DateTimePicker2.Value) & "' and '" & FormatDate(Me.DateTimePicker1.Value) & "'"
            ElseIf Me.CheckBox4.Checked = True And Me.CheckBox3.Checked = False Then
                DateStr = " and Convert(varchar(10),DeliverDate,21)>='" & FormatDate(Me.DateTimePicker2.Value) & "'"
            ElseIf Me.CheckBox4.Checked = False And Me.CheckBox3.Checked = True Then
                DateStr = " and Convert(varchar(10),DeliverDate,21)<='" & FormatDate(Me.DateTimePicker1.Value) & "'"
            End If

            If Me.TextBox14.Text.Length > 0 Then
                WhereStr += " and Barcode like '*" & Me.TextBox14.Text & "*%'"
            End If
            If Me.TextBox13.Text.Length > 0 Then
                WhereStr += " and SupperItem like '" & Me.TextBox13.Text & "%'"
            End If
            If Me.TextBox9.Text.Length > 0 Then
                WhereStr += " and Enname like '" & Me.TextBox9.Text & "%'"
            End If
            If Me.TextBox8.Text.Length > 0 Then
                WhereStr += " and Code like '" & Me.TextBox8.Text & "%'"
            End If

            If Me.TextBox11.Text.Length > 0 Then
                WhereStr2 = " and a.Batch like '" & Me.TextBox11.Text & "%'"
            End If
            If Me.TextBox12.Text.Length > 0 Then
                WhereStr2 += " and a.StorePlace like '" & Me.TextBox12.Text & "%'"
            End If


            If Me.cmbQtype.SelectedIndex = 0 Then
                mType = ""
            ElseIf Me.cmbQtype.SelectedIndex = 1 Then
                mType = " and mtype=1"
            ElseIf Me.cmbQtype.SelectedIndex = 2 Then
                mType = " and mtype=2"
            ElseIf Me.cmbQtype.SelectedIndex = 3 Then
                mType = " and mtype=0"
            End If

            sql = "select c.fShortName as StoreName,a.TradeType,a.DeliverDate,replace(a.GoodsBarcode,'*','') as BarCode,b.Code,b.Enname,b.Cnname,b.SupperItem,a.Batch,a.StorePlace,a.Goodsamount,mtype from " & vbCrLf
            sql += "(select storeHouse as StoreName,TradeType='期初庫存',DeliverDate=null,Barcode as GoodsBarCode,Batch,place as StorePlace,Beginqty as Goodsamount,mtype=0 from dbo.stor_storagehistory where 1=1 " & WhereStr & " and  StoreHouse='" & StoreName & "' and Period=(select FValue from dbo.BSC_SystemProfile where FCategory='Store' and FKey='Period_" & StoreName & "') and barcode in (select BarCode from BSC_Goods )" & vbCrLf
            sql += "  union all" & vbCrLf
            sql += " select ToStore as StoreName,TradeType=case when isnull(a.SmNum,'')='' then '入庫' when isnull(a.SmNum,'')<>'' then '庫位調整入' end,a.DeliverDate,"
            sql += " b.GoodsBarcode, b.Batch, b.StorePlace, Goodsamount=sum(b.Goodsamount),mtype=1"
            sql += " from dbo.Stor_TradeMaster a inner join  dbo.Stor_TradeDetail b on a.bonum=b.bonum where TradeType='+' and ToStore='" & StoreName & "' and GoodsBarcode in (select BarCode as GoodsBarcode from BSC_Goods where 1=1" & WhereStr & ")" & DateStr & "group by  ToStore,DeliverDate,GoodsBarcode,b.Batch,b.StorePlace,a.Smnum" & vbCrLf
            sql += " union all" & vbCrLf
            sql += " select FromStore as StoreName,TradeType=case when isnull(a.SmNum,'')='' then '出庫' when isnull(a.SmNum,'')<>'' then '庫位調整出' end,a.DeliverDate,"
            sql += " b.GoodsBarcode, b.Batch, b.StorePlace, Goodsamount=sum(b.Goodsamount),mtype=2"
            sql += " from dbo.Stor_TradeMaster a inner join  dbo.Stor_TradeDetail b on a.bonum=b.bonum where TradeType='-' and FromStore='" & StoreName & "' and GoodsBarcode in (select BarCode as GoodsBarcode from BSC_Goods where 1=1" & WhereStr & ")" & DateStr & "group by FromStore,DeliverDate,GoodsBarcode,b.Batch,b.StorePlace,a.Smnum" & vbCrLf
            sql += ") a left join BSC_Goods b on a.GoodsBarcode=b.Barcode "
            sql += " left join dbo.BSC_StoreHouse c on a.StoreName=c.fCode where 1=1 " & mType & "" & WhereStr2 & " order by DeliverDate"

            DetailDs = ReturnDataset(sql)

            Me.DataGridView1.DataSource = DetailDs.Tables(0)
            Me.DataGridView1.Columns("mtype").Visible = False

            GetToolEnable()
            Me.Cursor = Cursors.Default
        Catch ex As Exception
            Me.Cursor = Cursors.Default
            MsgBox("btnSelect_Click:" & ex.Message, MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly, Msg.CompanyName)
        Finally
            DetailDs = Nothing
        End Try

    End Sub

    ''' <summary>
    ''' 
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub DGV_Master_Scroll(ByVal sender As Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles DGV_Master.Scroll
        Me.dgv_Sum.HorizontalScrollingOffset = Me.DGV_Master.HorizontalScrollingOffset
    End Sub

    Private Sub DataGridView1_CellPainting(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellPaintingEventArgs) Handles DataGridView1.CellPainting

        Try
            'If e.ColumnIndex = 3 And e.ColumnIndex <> -1 Then
            '    Dim gridBrush As Brush = New SolidBrush(Me.DataGridView1.GridColor)

            '    Dim backColorBrush As Brush = New SolidBrush(e.CellStyle.BackColor)
            '    Dim gridLinePen As Pen = New Pen(gridBrush)
            '    e.Graphics.FillRectangle(backColorBrush, e.CellBounds)

            '    If e.RowIndex < Me.DataGridView1.Rows.Count - 1 And Me.DataGridView1.Rows(e.RowIndex + 1).Cells(e.ColumnIndex).Value.ToString <> e.Value.ToString Then
            '        e.Graphics.DrawLine(gridLinePen, e.CellBounds.Left, e.CellBounds.Bottom - 1, e.CellBounds.Right - 1, e.CellBounds.Bottom - 1)
            '        e.Graphics.DrawLine(gridLinePen, e.CellBounds.Right - 1, e.CellBounds.Top, e.CellBounds.Right - 1, e.CellBounds.Bottom)
            '    End If

            '    If Not e.Value Is Nothing Then
            '        If e.RowIndex > 0 And Me.DataGridView1.Rows(e.RowIndex - 1).Cells(e.ColumnIndex).Value.ToString <> e.Value.ToString Then

            '        Else
            '            e.Graphics.DrawString(e.Value.ToString, e.CellStyle.Font, Brushes.Black, e.CellBounds.X + 2, e.CellBounds.Y + 5, StringFormat.GenericDefault)
            '        End If
            '    End If
            '    e.Handled = True
            'End If
        Catch ex As Exception
            MsgBox(ex.ToString, MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly, Msg.CompanyName)
        End Try

    End Sub

    ''' <summary>
    ''' 
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub DataGridView1_RowPostPaint(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewRowPostPaintEventArgs) Handles DataGridView1.RowPostPaint
        Try
            e.Graphics.DrawString(e.RowIndex + 1, Me.DataGridView1.DefaultCellStyle.Font, Brushes.Black, e.RowBounds.Location.X + 5, e.RowBounds.Location.Y + 4)
        Catch ex As Exception
            MsgBox("DGV_Master_RowPostPaint:", MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly, Msg.CompanyName)
        End Try
    End Sub

    Private Sub ProgressBar(ByVal mValue As Integer)

        Dim CurrentWidth As Integer = Me.Panel6.Width

        If Me.Panel6.Width >= 100 Then
            Me.Panel6.Width = 10
            Me.Panel6.Visible = False
        Else
            Me.Panel6.Width += mValue
            Me.Labinfo.Text = Me.Panel6.Width & "%"
        End If

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim mDs As DataSet

        Try
            Me.Panel6.Visible = True
            Me.Labinfo.Visible = True
            Dim Pathstr As String = ""
            Dim SubPathstr As String = ""
            Dim ConfigNode() As String = ReadConfigFile.Split(";")
            Dim mServer As String = ""
            Dim mDataBase As String = ""
            Dim mUserID As String = ""
            Dim mPassword As String = ""
            Dim sql As String = ""
            Dim InOrOut As String = ""
            Dim StartDate As String = ""
            Dim EndDate As String = ""

            ProgressBar(10)
            'Pathstr = "D:\Reports\Store\RepInOutCount.rpt"
            Pathstr = GetReportPath("Store", "RepInOutCount.rpt")

            For i As Integer = 0 To ConfigNode.Length - 1
                If ConfigNode(i).Split("=")(0).ToLower = "Server".ToLower Then
                    mServer = ConfigNode(i).Split("=")(1)
                End If
                If ConfigNode(i).Split("=")(0).ToLower = "DataBase".ToLower Then
                    mDataBase = ConfigNode(i).Split("=")(1)
                End If
                If ConfigNode(i).Split("=")(0).ToLower = "Uid".ToLower Then
                    mUserID = ConfigNode(i).Split("=")(1)
                End If
                If ConfigNode(i).Split("=")(0).ToLower = "Pwd".ToLower Then
                    mPassword = ConfigNode(i).Split("=")(1)
                End If
            Next

            ProgressBar(10)
            Dim myReportDoc As New CrystalDecisions.CrystalReports.Engine.ReportDocument()
            Dim myParameterValues As New CrystalDecisions.Shared.ParameterValues
            Dim myDiscreteValue As New CrystalDecisions.Shared.ParameterDiscreteValue
            Dim logonInfo As New CrystalDecisions.Shared.TableLogOnInfo
            Dim table As CrystalDecisions.CrystalReports.Engine.Table
            ProgressBar(10)
            myReportDoc.Load(Pathstr)

            For Each table In myReportDoc.Database.Tables
                logonInfo = table.LogOnInfo
                With logonInfo.ConnectionInfo
                    .ServerName = mServer
                    .DatabaseName = mDataBase
                    .UserID = mUserID
                    .Password = mPassword
                End With
                table.ApplyLogOnInfo(logonInfo)
            Next
            If Me.ComboBox4.SelectedIndex = 0 Then
                InOrOut = ""
            ElseIf Me.ComboBox4.SelectedIndex = 1 Then
                InOrOut = "+"
            ElseIf Me.ComboBox4.SelectedIndex = 2 Then
                InOrOut = "-"
            End If
            ProgressBar(10)
            StartDate = FormatDate(Me.DateTimePicker3.Value)
            EndDate = FormatDate(Me.DateTimePicker4.Value)
            sql = "Exec Proc_InOutStore_Count '" & Me.ComboBox2.SelectedValue.ToString & "','" & InOrOut & "','" & StartDate & "','" & EndDate & "','" & Me.txtbarcode.Text & "','" & Me.txtEnname.Text & "','" & Me.txtSupperItem.Text & "'"


            mDs = New DataSet
            mDs = ReturnDataset(sql)
            ProgressBar(20)
            myReportDoc.SetParameterValue("StartDate", StartDate)
            myReportDoc.SetParameterValue("EndDate", EndDate)
            ProgressBar(10)
            myReportDoc.SetDataSource(mDs.Tables(0))
            ProgressBar(10)
            CrystalReportViewer1.ReportSource = myReportDoc
            Dim TxtStartDate As CrystalDecisions.CrystalReports.Engine.TextObject = myReportDoc.ReportDefinition.ReportObjects("Text23")
            Dim TxtEndDate As CrystalDecisions.CrystalReports.Engine.TextObject = myReportDoc.ReportDefinition.ReportObjects("Text24")
            TxtStartDate.Text = Format(Me.DateTimePicker3.Value.ToString("yyyy/MM/dd"), "yyyy/MM/dd")
            TxtEndDate.Text = Format(Me.DateTimePicker4.Value.ToString("yyyy/MM/dd"), "yyyy/MM/dd")
            ProgressBar(10)
            CrystalReportViewer1.Zoom(1)
            Me.Panel6.Visible = False
            Me.Labinfo.Visible = False
        Catch ex As Exception
        Finally
            mDs = Nothing
        End Try

    End Sub

#End Region



    Private Sub TextBox7_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox7.TextChanged

    End Sub
End Class
